<template>
  <div>
    <el-form
      ref="dataForm"
      :model="dataForm"
      :rules="dataRule"
      label-width="100px"
      @keyup.enter.native="dataFormSubmit()"
    >
      <el-form-item label="所属数据源">
        <el-input disabled v-model="dataForm.paramKey" />
      </el-form-item>
      <el-form-item label="数据库名称" prop="paramValue">
        <el-input v-model="dataForm.paramValue" placeholder="数据库名称" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="$emit('close')">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      dataForm: {
        id: 0,
        paramKey: "",
        paramValue: "",
        remark: ""
      },
      dataRule: {
        paramValue: [
          { required: true, message: "参数值不能为空", trigger: "blur" }
        ]
      }
    };
  },
  methods: {
    // 表单提交
    dataFormSubmit() {
      this.$refs["dataForm"].validate(valid => {
        if (valid) {
          this.$emit("close");
        }
      });
    }
  }
};
</script>
